<!DOCTYPE html>
<html>

	
    <head th:include="/common/commonResource" >
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  	</head>

  
<body class="cbp-spmenu-push">
	<div class="main-content">
    
    
    
    
    
    
    
    
    
    
    	<div class="vlid-grid2">
				
						
						<div class="valid-top3">
							
						 <section>
							<form id="defaultForm" method="post" class="form-horizontal" action="inputs.html">
								<div class="form-group">
									<label class="col-sm-3 control-label">新增作者</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="authorName" placeholder="作者姓名.." />
									</div>
								</div>
								
								
								
								<div class="form-group">
									<label class="col-sm-3 control-label">真实姓名(选填)</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="realName" placeholder="真实姓名.." />
									</div>
								</div>
								
								
								<div class="form-group">
									<label class="col-sm-3 control-label">作者描述</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="introduction" placeholder="作者描述.." />
									</div>
								</div>
	
								
								<label class="col-lg-3 control-label">选择作者图片</label>
								<div>
									<form class="form-horizontal required-validate" action="/pictrueUpload" enctype="multipart/form-data" method="post" onsubmit="return iframeCallback(this, pageAjaxDone)">

									    <div class="form-group">
									        <div class="col-md-10 tl th">
									            <input type="file" id="uploadfile1" name="image" class="projectfile" value="${deal.image}" />
									        </div>
									    </div>  
									    <!--  
									    <div class="form-group text-center ">
									        <div class="col-md-10 col-md-offset-1">
									            <button type="submit" class="btn btn-primary btn-lg">保存1</button>
									        </div>
									    </div>-->
									</form>
								</div>    
								
								<input type="hidden" id="imgsrc" value=""/>
								
								
								
								
								
								
								
							
								
							</form>
								<div class="form-group">
										<div class="col-lg-9 col-lg-offset-3">
											<button id="sub" onclick="authorSub();"class="btn btn-primary">提交模块</button>
										</div>
								</div>							
							 </section>
						</div>
						
						
						
    
    
    
    
    
    
    
    
    
    
    	</div>
   </div>
    
    
    
    	<script src="/behind/js/classie.js"></script>
		<script src="/js/fileinput.min.js"></script>
	    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.js"> </script>
		<script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
		
		<script>
					var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
						showLeftPush = document.getElementById( 'showLeftPush' ),
						body = document.body;
						
					showLeftPush.onclick = function() {
						classie.toggle( this, 'active' );
						classie.toggle( body, 'cbp-spmenu-push-toright' );
						classie.toggle( menuLeft, 'cbp-spmenu-open' );
						disableOther( 'showLeftPush' );
					};
					

					function disableOther( button ) {
						if( button !== 'showLeftPush' ) {
							classie.toggle( showLeftPush, 'disabled' );
						}
					}
				</script>
			<!-- Bootstrap Core JavaScript --> 
				
				<script type="text/javascript" src="/behind/js/bootstrap.min.js"></script>
				<!--scrolling js-->
				<script src="/behind/js/jquery.nicescroll.js"></script>
				<script src="/behind/js/scripts.js"></script>
				<!--//scrolling js-->
				
				<!--//scrolling js-->
				<script type="text/javascript">
				
				//初始化fileinput控件（第一次初始化）
							function iframeCallback(form, callback) {
							alert("a")
			    YUNM.debug("带文件上传处理");
			
			    var $form = $(form), $iframe = $("#callbackframe");
				
			    var data = $form.data('bootstrapValidator');
			    if (data) {
			        if (!data.isValid()) {
			            return false;
			        }
			    }
			
			    // 富文本编辑器
			    $("div.summernote", $form).each(function() {
			        var $this = $(this);
			
			        if (!$this.summernote('isEmpty')) {
			            var editor = "<input type='hidden' name='" + $this.attr("name") + "' value='" + $this.summernote('code') + "' />";
			            $form.append(editor);
			        } else {
			            $.showErr("请填写项目详情");
			            return false;
			        }
			
			    });
			
			    if ($iframe.size() == 0) {
			        $iframe = $("<iframe id='callbackframe' name='callbackframe' src='about:blank' style='display:none'></iframe>").appendTo("body");
			    }
			    if (!form.ajax) {
			        $form.append('<input type="hidden" name="ajax" value="1" />');
			    }
			    form.target = "callbackframe";
			
			    _iframeResponse($iframe[0], callback || YUNM.ajaxDone);
			}
			function _iframeResponse(iframe, callback) {
			    var $iframe = $(iframe), $document = $(document);
			
			    $document.trigger("ajaxStart");
			
			    $iframe.bind("load", function(event) {
			        $iframe.unbind("load");
			        $document.trigger("ajaxStop");
			
			        if (iframe.src == "javascript:'%3Chtml%3E%3C/html%3E';" || // For
			        // Safari
			        iframe.src == "javascript:'<html></html>';") { // For FF, IE
			            return;
			        }
			
			        var doc = iframe.contentDocument || iframe.document;
			
			        // fixing Opera 9.26,10.00
			        if (doc.readyState && doc.readyState != 'complete')
			            return;
			        // fixing Opera 9.64
			        if (doc.body && doc.body.innerHTML == "false")
			            return;
			
			        var response;
			
			        if (doc.XMLDocument) {
			            // response is a xml document Internet Explorer property
			            response = doc.XMLDocument;
			        } else if (doc.body) {
			            try {
			                response = $iframe.contents().find("body").text();
			                response = jQuery.parseJSON(response);
			            } catch (e) { // response is html document or plain text
			                response = doc.body.innerHTML;
			            }
			        } else {
			            // response is a xml document
			            response = doc;
			        }
			
			        callback(response);
			    });
			}
				
							function initFileInput(ctrlName,uploadUrl) {      
						        var control = $('#' + ctrlName);   
						        control.fileinput({  
						            language: 'zh', //设置语言  
						            uploadUrl: uploadUrl,  //上传地址  
						            showUpload: false, //是否显示上传按钮  
						            showRemove:true,  
						             dropZoneEnabled: false,  
						            showCaption: true,//是否显示标题  
						            allowedPreviewTypes: ['image'],  
						                allowedFileTypes: ['image'],  
						                allowedFileExtensions:  ['jpg', 'png'],  
						                maxFileSize : 2000,  
						            maxFileCount: 1,  
						            //initialPreview: [   
						                    //预览图片的设置  
						              //      "<img src='http://127.0.0.1:8080/NewsManageSys/plugin/umeditor1_2_2/jsp/upload/20161030/55061                       477813913474.jpg' class='file-preview-image' alt='肖像图片' title='肖像图片'>",  
						            //],  
						              
						        }).on("filebatchselected", function(event, files) {  
						          	
						            $(this).fileinput("upload");  
						            })  
						            .on("fileuploaded", function(event,data,result) {
						           	//解析json对象
						            //alert(JSON.stringify(data.response));
						              $("#imgsrc").val(data.response.aaa);
						             $("#path").attr("value",data.response);  
						        });  
						    }  
							 
						    
						function authorSub(){
						
							var imgsrc = $("#imgsrc").val();
					      	var authorName = $("#authorName").val();
					      	var realName = $("#realName").val();
					      	var introduction = $("#introduction").val();
							
							var data1 ={
							"authorName":authorName,
							"realName":realName,
							"introduction":introduction,
							"imgsrc":imgsrc
							}
							$.ajax({
								url : "insertAuthor",
								type: "post",
								dataType : "json",
								data : data1,
					
								success : function(data) {
								alert(data.result)
									if (data.result == '插入成功') {
									alert("1")
										window.location.href="/beforeGetArticle"
										return;
									}
									
								}	
							});
							
						}
						    
						    
						    
					 	$(document).ready(function(){  	
							 var path="/pictrueUpload";  
       						initFileInput("uploadfile1",path); 
							createEditor();
							
						});
				
						
										
						
						
						
						
								</script>
    
    
    
  </body>
</html>
